// package: {{{packageName}}}
// file: {{{fileName}}}

/* tslint:disable */
/* eslint-disable */

{{#each imports}}
{{{this}}}
{{/each}}
{{#each services}}

interface I{{{serviceName}}}Service extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
    {{#each methods}}
    {{lcFirst methodName}}: I{{{serviceName}}}Service_I{{{methodName}}};
    {{/each}}
}

    {{#each methods}}
interface I{{{serviceName}}}Service_I{{{methodName}}} extends grpc.MethodDefinition<{{{requestTypeName}}}, {{{responseTypeName}}}> {
    path: "/{{{packageName}}}{{#if packageName}}.{{/if}}{{{serviceName}}}/{{{methodName}}}";
    requestStream: {{{requestStream}}};
    responseStream: {{{responseStream}}};
    requestSerialize: grpc.serialize<{{{requestTypeName}}}>;
    requestDeserialize: grpc.deserialize<{{{requestTypeName}}}>;
    responseSerialize: grpc.serialize<{{{responseTypeName}}}>;
    responseDeserialize: grpc.deserialize<{{{responseTypeName}}}>;
}
    {{/each}}

export const {{{serviceName}}}Service: I{{{serviceName}}}Service;

export interface I{{{serviceName}}}Server{{#if (fetchIsGrpcJs)}} extends grpc.UntypedServiceImplementation{{/if}} {
    {{#each methods}}
        {{#eq type "ClientUnaryCall"}}
    {{lcFirst methodName}}: grpc.handleUnaryCall<{{{requestTypeName}}}, {{{responseTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientWritableStream"}}
            {{#if (fetchIsGrpcJs)}}
    {{lcFirst methodName}}: grpc.handleClientStreamingCall<{{{requestTypeName}}}, {{{responseTypeName}}}>;
            {{else}}
    {{lcFirst methodName}}: grpc.handleClientStreamingCall<{{{requestTypeName}}}, {{{responseTypeName}}}>;
            {{/if}}
        {{/eq}}
        {{#eq type "ClientReadableStream"}}
    {{lcFirst methodName}}: grpc.handleServerStreamingCall<{{{requestTypeName}}}, {{{responseTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientDuplexStream"}}
    {{lcFirst methodName}}: grpc.handleBidiStreamingCall<{{{requestTypeName}}}, {{{responseTypeName}}}>;
        {{/eq}}
    {{/each}}
}

export interface I{{{serviceName}}}Client {
    {{#each methods}}
        {{#eq type "ClientUnaryCall"}}
    {{lcFirst methodName}}(request: {{{requestTypeName}}}, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
    {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
    {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
        {{/eq}}
        {{#eq type "ClientWritableStream"}}
    {{lcFirst methodName}}(callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    {{lcFirst methodName}}(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    {{lcFirst methodName}}(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    {{lcFirst methodName}}(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientReadableStream"}}
    {{lcFirst methodName}}(request: {{{requestTypeName}}}, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<{{{responseTypeName}}}>;
    {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<{{{responseTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientDuplexStream"}}
    {{lcFirst methodName}}(): grpc.ClientDuplexStream<{{{requestTypeName}}}, {{{responseTypeName}}}>;
    {{lcFirst methodName}}(options: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<{{{requestTypeName}}}, {{{responseTypeName}}}>;
    {{lcFirst methodName}}(metadata: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<{{{requestTypeName}}}, {{{responseTypeName}}}>;
        {{/eq}}
    {{/each}}
}

export class {{{serviceName}}}Client extends grpc.Client implements I{{{serviceName}}}Client {
    {{#if (fetchIsGrpcJs)}}
    constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial<grpc.ClientOptions>);
    {{else}}
    constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
    {{/if}}
    {{#each methods}}
        {{#eq type "ClientUnaryCall"}}
    public {{lcFirst methodName}}(request: {{{requestTypeName}}}, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
    public {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
    public {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientUnaryCall;
        {{/eq}}
        {{#eq type "ClientWritableStream"}}
    public {{lcFirst methodName}}(callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    public {{lcFirst methodName}}(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    public {{lcFirst methodName}}(options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
    public {{lcFirst methodName}}(metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: {{{responseTypeName}}}) => void): grpc.ClientWritableStream<{{{requestTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientReadableStream"}}
    public {{lcFirst methodName}}(request: {{{requestTypeName}}}, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<{{{responseTypeName}}}>;
    public {{lcFirst methodName}}(request: {{{requestTypeName}}}, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<{{{responseTypeName}}}>;
        {{/eq}}
        {{#eq type "ClientDuplexStream"}}
    public {{lcFirst methodName}}(options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<{{{requestTypeName}}}, {{{responseTypeName}}}>;
    public {{lcFirst methodName}}(metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientDuplexStream<{{{requestTypeName}}}, {{{responseTypeName}}}>;
        {{/eq}}
    {{/each}}
}
{{/each}}
